let { ipcRenderer } = require('electron')

let { BrowserWindow } = require('electron').remote

let mainWin = null

ipcRenderer.on('openNewsFirst', (e, data) => {
  mainWin = BrowserWindow.fromId(data.mainWinId)
})

ipcRenderer.on('applyMesg', (e, data) => {
  console.log('接收到消息', data)
})


window.onload = () => {
  let btn = document.querySelector('#btn')

  // 传递一条消息给MainWin
  btn.onclick = () => {
    mainWin.webContents.send('applyMesg', {
      id: 2
    })
  }
}